package com.zbkj.common.request.user;

import com.zbkj.common.exception.CommonException;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * @Auther:
 * @Date: 2024/9/15 13:36
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "ClientUserInvoiceRequest对象", description = "客户端-用户发票保存请求对象")
public class ClientUserInvoiceRequest implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("抬头类型：1 企业")
    @NotNull(message = "抬头类型不能为空")
    private Integer headType;

    @ApiModelProperty("发票抬头")
    @NotBlank(message = "发票抬头不能为空")
    private String headName;

    @ApiModelProperty("发票类型：1 増値税普通发票 2 增值税专用发票")
    @NotNull(message = "发票类型不能为空")
    @Range(min = 1, max = 2, message = "发票类型参数错误")
    private Integer invoiceType;

    @ApiModelProperty("统一社会信用代码")
    @NotBlank(message = "统一社会信用代码不能为空")
    private String creditCode;

    @ApiModelProperty("开户银行名称")
    private String bankName;

    @ApiModelProperty("基本开户账号")
    private String basicAccount;

    @ApiModelProperty("注册场所地址")
    private String registeAddr;

    @ApiModelProperty("注册固定电话")
    private String registePhone;

    public void type2ParamCheck() {
        if(StringUtils.isBlank(bankName)) {
            throw new CommonException("开户银行名称不能为空");
        }
        if(StringUtils.isBlank(basicAccount)) {
            throw new CommonException("基本开户账号不能为空");
        }
        if(StringUtils.isBlank(registeAddr)) {
            throw new CommonException("注册场所地址不能为空");
        }
        if(StringUtils.isBlank(registePhone)) {
            throw new CommonException("注册固定电话不能为空");
        }
    }
}
